home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / June 96 / Re Extension Link Problem < prev    next >
Encoding:
Internet Message Format  |  1996-12-03  |  3.3 KB  |  [TEXT/ttxt]

  1. Subject:     Re:Extension Link Problem
  2. Sent:        6/7/96 8:37 AM
  3. Received:    6/7/96 8:51 AM
  4. From:        Greg Friedman, friedman@cognosis.com
  5. Reply-To:    ODF Interest, ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8. At 10:19 AM 6/7/96, Doyle Rhynard wrote:>     I am having a problem with
  9. linking a client part when I reference an
  10. > extension defined in another part. This the IDL file that I am using to
  11. > define the extension, TestExt:
  12. >
  13. >   #ifndef TestExt_IDL
  14. >     #define TestExt_IDL
  15. >
  16.  
  17. The problem you describe is caused by the fact that the linker cannot find
  18. the class data symbol for your client's extension. There are two solutions
  19. for the problem; one is better than the other.
  20.  
  21. The less preferable solution is to link your client part against your
  22. server part's shared library. For this to work, you must make sure that
  23. your extension's class data symbol is exported from your server part, by
  24. adding the line:
  25.  
  26. ADI_TestExtClassData
  27.  
  28. to your server's .exp file. Make sure you REMOVE any of the specific
  29. methods implemented by your extension from your server's .exp file. In the
  30. SOM world, only a class data symbol should be exported, not method names.
  31.  
  32. This solution has two shortcomings:
  33.  
  34. 1). SOM, as it is specified, really wants just one definition of a specific
  35. class name per machine. If you create multiple part editors, each of which
  36. can serve the same extension, and statically link the extension's
  37. definition into each part, you have introduced multiple definitions of the
  38. extension. In simplistic terms, you can think of SOM as providing an object
  39. factory. When you try to instantiate an instance of a particular class, SOM
  40. looks up the implementation of the class by name, and creates and returns
  41. an instance. Multiple part editors that each implement the same extension
  42. muddle this model, and SOM won't necessarily instantiate the correct
  43. implementation. It happens that the current Mac implementation of SOM has
  44. optimizations that have a side-effect of eliminating collision problems in
  45. most cases. Your specific use case will not have a collision problem.
  46. Still, since the SOM spec doesn't support it, you're better off in the long
  47. term if you avoid the problem now.
  48.  
  49. 2). Once you've distributed multiple part editors that use your extension,
  50. you'll have to update each part editor for it to get any fixes you make to
  51. your extension. In other words, if you write SurfWriter and SurfDraw, each
  52. of which statically link your SurfsUp extension, and later release a new
  53. version of SurfDraw that has an updated SurfsUp extension, SurfWriter will
  54. not get the SurfsUp fixes.
  55.  
  56. The better solution to your problem is this:
  57.  
  58. Create a new shared library that implements only your extension. From this
  59. shared library, export only the extension's class data, as described in the
  60. first solution. Link both your client and your server parts against the new
  61. shared library.
  62.  
  63. With this model, any server part that provides the extension will always
  64. provide the same version and implementation. You can upgrade the extension
  65. without having to touch all of the server parts that provide it. And,
  66. finally, you avoid instantiation collisions.
  67.  
  68. gsf.
  69.  
  70.  
  71. _________________________________________________________
  72. Greg Friedman      ODF Engineering       Apple Computer
  73.  
  74.